package cn.itsource.ymcc.feign.fallback;

import cn.itsource.ymcc.doc.CourseDoc;
import cn.itsource.ymcc.feign.client.CourseDocFeignClient;
import cn.itsource.ymcc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class CourseDocFeignClientFallbackFactory implements FallbackFactory<CourseDocFeignClient> {
    @Override
    public CourseDocFeignClient create(Throwable throwable) {
        throwable.printStackTrace();
        return new CourseDocFeignClient() {
            @Override
            public JSONResult online(CourseDoc courseDoc) {
                return JSONResult.error("ES课程上线失败！","500");
            }
        };
    }
}
